home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15266 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: acsu.buffalo.edu!rastrl
  2. From: rastrl@cs.buffalo.edu (Robert L Rast)
  3. Newsgroups: comp.infosystems.www.servers.unix,comp.lang.c
  4. Subject: Re: Opening a binary file.... (dealing with content-type & WWW)
  5. Date: 18 Apr 1996 08:08:36 GMT
  6. Organization: State University of New York at Buffalo/Computer Science
  7. Message-ID: <4l4ta4$7d1@azure.acsu.buffalo.edu>
  8. References: <317351DE.E7E@draper.com>
  9. NNTP-Posting-Host: gagarin.cs.buffalo.edu
  10. NNTP-Posting-User: rastrl
  11.  
  12. In article <317351DE.E7E@draper.com>,
  13. Brandon Shalton  <bshalton@draper.com> wrote:
  14. >Hello, 
  15. >
  16. >I am trying to establish content-types (mime) based upon the header 
  17. >of the file, rather than relying on the file extension.  I have 
  18. >instances where file extensions overlap...ex. .doc (microsoft word), 
  19. >.doc (ascii text document).
  20. >
  21. >This is my first cut...
  22.  
  23. >                fd2=open(entries[0].val,O_RDONLY);
  24. >                for(;;)
  25. >                        {
  26. >                if(     read(fd2, tbuf, 1) <=0 ) exit(1);
  27. >                        printf("%s", tbuf);
  28. >                        }
  29. >
  30. >
  31.  
  32. Just taking a guess here, but use write instead of printf. You can get 
  33. the number of bytes from the return from 'read'.
  34.  
  35. The binary characters (null, eof, etc.) are being interpreted by printf.
  36.  
  37.  
  38. R.L.Rast ;'./
  39.  
  40.                     "Putting out fires with gasoline."
  41.                             __   (.x.)   __
  42. --rastrl@acsu.buffalo.edu--(,,^\--\-/--/^,,)--www.acsu.buffalo.edu/~rastrl--  
  43.  
  44.  
  45.  
  46.